﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ExpressionEvaluator;
using ExpressionEvaluator.Expression;

namespace Calculator.Expression.Unary
{
    public class Factorial : UnaryAbstract
    {
        int priority;

        public Factorial(Expr v)
        {
            Value = fact(v.Value);
        }

        public override string ToString()
        {
            return Value.ToString();
        }

        public override string Name
        {
            get { return Value.ToString(); }
        }

        private double fact(double n)
        {
            if (n == 0) return 1;
            else return n * fact(n - 1);
        }

        public override Expr diff(Expr expr)
        {
            throw new NotImplementedException();
        }
    }
}
